package com.zhi.util;

import com.zhi.config.Constant;

import lombok.Data;

@Data
public class PageUtil {
	
	//当前页
	private Integer pageIndex;
	//总页数
	private Integer totalPages;
	//每页数量
	private Integer size;

	//此属性用于查询带条件，可带5个查询条件
	private String para01;
	private String para02;
	private String para03;
	private String para04;
	private String para05;

	
	//初始化分页工具参数
	public static PageUtil init(PageUtil pageUtil) {
		
		Integer index = pageUtil.getPageIndex();
    	Integer size = pageUtil.getSize();
		Integer pages = pageUtil.getTotalPages();

    	index = index==null?1:index;
    	size = size==null?Constant.PAGE_COUNT_DEFAULT:size;
		pages = pages==null?1:pages;

    	pageUtil.setPageIndex(index);
    	pageUtil.setSize(size);
		pageUtil.setTotalPages(pages);

		return pageUtil;
	}

}
